package bancosys.tec.security.impl.services.executar;

import java.security.Principal;
import java.util.Collections;
import java.util.HashSet;

import javax.security.auth.Subject;

import bancosys.tec.security.SecurityException;
import bancosys.tec.security.SecurityManager;
import bancosys.tec.security.impl.AbstractSecurityManager;
import bancosys.tec.security.impl.SecurityPrincipal;

public class DummySecurityManager extends AbstractSecurityManager<Object> implements SecurityManager<Object> {

    private Subject subject;

    public Subject loadSubject(Object context) throws SecurityException {
        return subject;
    }

    public Subject login(String username, String password, Object context) throws SecurityException {
        return new Subject(false, Collections.<Principal> singleton(new SecurityPrincipal(username)), new HashSet<Object>(),
                new HashSet<Object>());
    }

    public void logout(Object context) {
        this.subject = null;
    }

    public void storeSubject(Object context, Subject subject) {
        this.subject = subject;
    }

}
